package com.hjb.service.impl.app;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hjb.service.app.BrokerUserService;
import com.hjb.service.domain.brokerUser.BrokerUser;
import com.hjb.service.mapper.BrokerUserMapper;
import com.hjb.service.utils.MD5Utils;

import tk.mybatis.mapper.entity.Example;

@Service
public class BrokerUserServiceImpl implements BrokerUserService {
	@Autowired
	private BrokerUserMapper brokerUserMapper;
	@Override
	public List<BrokerUser> getBrokerUser(String loginName, String loginPassword) {
		Example example = new Example(BrokerUser.class);
		example.createCriteria().andEqualTo("loginName", loginName).andEqualTo("password", MD5Utils.encrypt(loginPassword));
		return brokerUserMapper.selectByExample(example);
	}
	@Override
	public int updatePassword(BrokerUser brokerUser) {
		Example example = new Example(BrokerUser.class);
		example.createCriteria().andEqualTo("loginName", brokerUser.getLoginName());
		return brokerUserMapper.updateByExampleSelective(brokerUser, example);
	}
}
